//
//  JSONUtilities.m
//  ContactViewerIos
//
//  Created by Mitchell Sans Souci on 3/26/12.
//  Copyright (c) 2012 Tiny Mission. All rights reserved.
//

#import "JSONUtilities.h"

@implementation JSONUtilities

+(NSString*) dictionaryToJSON:(NSDictionary*) dictionaryToConvert
{
    //convert object to data
    NSError* error;
    NSData* jsonData = [NSJSONSerialization dataWithJSONObject:dictionaryToConvert options:NSJSONWritingPrettyPrinted error:&error];
    
    NSString* jsonString = [[NSString alloc] initWithData:jsonData 
                                                 encoding:NSUTF8StringEncoding];  
    
    return jsonString;
}

+(NSDictionary*) dictionaryFromJSON:(NSString*) jsonString
{
    NSData* jsonData = [jsonString dataUsingEncoding:NSUTF8StringEncoding];
    NSError* error;
    NSDictionary* jsonDictionary = [NSJSONSerialization JSONObjectWithData:jsonData options:kNilOptions error:&error];
    
    return jsonDictionary;
}

@end
